using System;
using System.Drawing;
namespace ICSharpCode.TextEditor.Document
{
	public class FontContainer
	{
		private Font defaultFont;
		private Font regularfont;
		private Font boldfont;
		private Font italicfont;
		private Font bolditalicfont;
		private static float twipsPerPixelY;
		public Font RegularFont
		{
			get
			{
				return this.regularfont;
			}
		}
		public Font BoldFont
		{
			get
			{
				return this.boldfont;
			}
		}
		public Font ItalicFont
		{
			get
			{
				return this.italicfont;
			}
		}
		public Font BoldItalicFont
		{
			get
			{
				return this.bolditalicfont;
			}
		}
		public static float TwipsPerPixelY
		{
			get
			{
				if (FontContainer.twipsPerPixelY == 0f)
				{
					using (Bitmap bitmap = new Bitmap(1, 1))
					{
						using (Graphics graphics = Graphics.FromImage(bitmap))
						{
							FontContainer.twipsPerPixelY = 1440f / graphics.DpiY;
						}
					}
				}
				return FontContainer.twipsPerPixelY;
			}
		}
		public Font DefaultFont
		{
			get
			{
				return this.defaultFont;
			}
			set
			{
				float num = (float)Math.Round((double)(value.SizeInPoints * 20f / FontContainer.TwipsPerPixelY));
				this.defaultFont = value;
				this.regularfont = new Font(value.FontFamily, num * FontContainer.TwipsPerPixelY / 20f, FontStyle.Regular);
				this.boldfont = new Font(this.regularfont, FontStyle.Bold);
				this.italicfont = new Font(this.regularfont, FontStyle.Italic);
				this.bolditalicfont = new Font(this.regularfont, FontStyle.Bold | FontStyle.Italic);
			}
		}
		public static Font ParseFont(string font)
		{
			string[] array = font.Split(new char[]
			{
				',', 
				'='
			});
			return new Font(array[1], float.Parse(array[3]));
		}
		public FontContainer(Font defaultFont)
		{
			this.DefaultFont = defaultFont;
		}
	}
}
